package come.demo.widgets;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import come.demo.widgets.ui.CustomNestedActivity;
import come.demo.widgets.ui.HeaderFooterActivity;
import come.demo.widgets.ui.MultipleListActivity;
import come.demo.widgets.ui.PictureActivity;
import come.demo.widgets.ui.RefreshActivity;
import come.demo.widgets.ui.RefreshActivity2;
import come.demo.widgets.ui.SpringbackActivity;
import come.demo.widgets.utils.ActivityContext;
import come.demo.widgets.utils.PermissionsCheckUtils;
import tzy.refreshlayout.CustomRefreshLayout;

import static come.demo.widgets.utils.PermissionsCheckUtils.REQUEST_IMAGE;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, ActivityContext {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.picture).setOnClickListener(this);
        findViewById(R.id.header_footer).setOnClickListener(this);
        findViewById(R.id.refresh).setOnClickListener(this);
        findViewById(R.id.refresh2).setOnClickListener(this);
        findViewById(R.id.custom_nested).setOnClickListener(this);
        findViewById(R.id.spring_back).setOnClickListener(this);
        findViewById(R.id.multiple_adapter).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.picture:
                if (!PermissionsCheckUtils.lackAndRequestPermissions(MainActivity.this, REQUEST_IMAGE, PermissionsCheckUtils.STORAGE_PERMISSIONS)) {
                    PictureActivity.gotoActivity(this);
                }
                break;
            case R.id.header_footer:
                HeaderFooterActivity.gotoActivity(this);
                break;
            case R.id.refresh:
                RefreshActivity.gotoActivity(this);
                break;
            case R.id.refresh2:
                RefreshActivity2.gotoActivity(this);

                break;
            case R.id.custom_nested:
                CustomNestedActivity.gotoActivity(this);
                break;
            case R.id.spring_back:
                SpringbackActivity.gotoActivity(this);
                break;
            case R.id.multiple_adapter:
                MultipleListActivity.gotoActivity(this);
                break;
        }
    }

    @Override
    public Activity getActivity() {
        return this;
    }
}
